<?php
/**
 * @category   Application_Extensions
 * @package    Talktangle Plugin 
 * @copyright  Idragon Co., Ltd.
 * @license
 */
class Talktangle_Widget_FiltertangleController extends Engine_Content_Widget_Abstract {
		
	public function indexAction() {
	    $request = Zend_Controller_Front::getInstance()->getRequest();
        $this->view->search = $search = $request->getParam('id','');
        $id = $request->getParam('id');
        $supportid = array(
            'talktangles'   => 'talk',
            'crosstangles'  => 'cross',
            'pictangles'     => 'pic',
            'vidtangles'     => 'vid'
        );
        
        if (!in_array($id,$supportid)) {
            $this->view->notsupportId = true;
            return;
        }
        
        $keys = array_flip($supportid);
        $tangleT = Engine_Api::_()->getDbtable($keys[$id],'talktangle');
        $select = $tangleT->select()
                          ->where('winner_id = 0')
                          //->where('duration > ?' ,time()) 
                          ->order('creation_date desc');
       
        $this->view->paginator = $paginator = Zend_Paginator::factory($select);

        // Set item count per page and current page number
        $paginator->setItemCountPerPage($this->_getParam('itemCountPerPage', 4));
        $paginator->setCurrentPageNumber($this->_getParam('page', 1));
        $this->view->paginator = $paginator;
     
       
	}
}